package com.smile.f213;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class SimpleEvent {
	public void createUI(){
		JFrame frame = new JFrame("简单事件处理示例");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JButton button = new JButton("单击按钮进行测试");
		button.addActionListener(new ClickAction()); //添加事件监听器
		frame.getContentPane().add(button);
		frame.setSize(250,120);
		frame.setVisible(true);
	}
	//事件处理内部类
	class ClickAction implements ActionListener{
		@Override
		public void actionPerformed(ActionEvent e) {
			System.out.println("用户执行了单击按钮操作");
		}
	}
	public static void main(String[] args) {
		SimpleEvent example = new SimpleEvent();
		example.createUI();
	}
}